package com.woniuxy.educationplatform.service.impl;

import com.woniuxy.educationplatform.bean.CourseBean;
import com.woniuxy.educationplatform.mapper.CourseMapper;
import com.woniuxy.educationplatform.service.ICourseService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CourseServiceImpl implements ICourseService {

    @Resource
    private CourseMapper courseMapperImpl;

    @Override
    public CourseBean findById(Long id) {
        return courseMapperImpl.findById(id);
    }

    @Override
    public List<CourseBean> findAll() {
        return courseMapperImpl.findAll();
    }

    @Override
    public List<CourseBean> findOneByCondition(String courseName, Long id) {
        return courseMapperImpl.findOneByCondition(courseName, id);
    }

    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public void delete(Long id) {
        courseMapperImpl.delete(id);
    }

    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public void saveCourseBean(CourseBean courseBean) {
        courseMapperImpl.saveCourseBean(courseBean);
    }

    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public void updateCourseBean(CourseBean courseBean) {
        courseMapperImpl.updateCourseBean(courseBean);
    }

    @Override
    public String[] getCourseName() {
        return courseMapperImpl.getCourseName();
    }
}
